package com.lnking.lnkingplace.Util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexPhoneUtil {
    private static String REGEX_PHONE = "^[1][3,4,5,6,7,8,9][0-9]{9}$";

    /**
     * 校验手机号格式是否正确
     * @param phone
     * @return
     */
    public static Boolean regexPhone(String phone) {
        if(null != phone){
            phone = phone.trim();
        }
        Boolean b;
        if (phone.length() != 11) {
            b = false;
        } else {
            Pattern p = Pattern.compile(REGEX_PHONE);
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
            if (isMatch) {
                b = true;
            } else {
                b = false;
            }
        }
        return b;
    }

    public static void main(String[] args) {
        Boolean aBoolean = regexPhone("18728575384");
        System.out.println(aBoolean);
    }
}
